<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__withdrawal}">
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item>
          <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t('query') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="info" @click="exportHandle()">{{ $t('export') }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button v-if="$hasPermission('sys:withdrawal:delete')" type="danger" @click="deleteHandle()">{{ $t('deleteBatch') }}</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle" style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="userId" :label="$t('withdrawal.userId')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="userName" :label="$t('withdrawal.userName')" width="150" header-align="center" align="center"></el-table-column>
        <el-table-column prop="withdrawalMoney" :label="$t('withdrawal.withdrawalMoney')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="realityMoney" :label="$t('withdrawal.realityMoney')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="frontVacancies" :label="$t('withdrawal.frontVacancies')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="behindVacancies" :label="$t('withdrawal.behindVacancies')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="serviceCharge" :label="$t('withdrawal.serviceCharge')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="serviceChargeScale" :label="$t('withdrawal.serviceChargeScale')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="makeCollectionsUrl" :label="$t('withdrawal.makeCollectionsUrl')" header-align="center" align="center">
          <template slot-scope="scope">
          <!-- <img :src="scope.row.makeCollectionsUrl" width="60" height="60" alt=""/> -->
          <el-image
              @click="
                bigImg(scope.row.makeCollectionsUrl)
              "
              style="width: 50px; height: 50px; margin-bottom:-4px"
              :src="scope.row.makeCollectionsUrl"
              :preview-src-list="srcList"
            >
          </el-image>
        </template>
        </el-table-column>
        <el-table-column prop="type" :label="$t('withdrawal.type')" sortable="custom" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.type === 1" size="small">{{ $t('withdrawal.type1') }}</el-tag>
            <el-tag v-if="scope.row.type === 2" size="small" type="success">{{ $t('withdrawal.type2') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="status" :label="$t('withdrawal.status')" sortable="custom" header-align="center" align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 0" size="small">{{ $t('withdrawal.status0') }}</el-tag>
            <el-tag v-if="scope.row.status === 1" size="small" type="success">{{ $t('withdrawal.status1') }}</el-tag>
            <el-tag v-if="scope.row.status === 2" size="small" type="danger">{{ $t('withdrawal.status2') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="content" :label="$t('withdrawal.content')" width="250" header-align="center" align="center"></el-table-column>
        <el-table-column prop="time" :label="$t('withdrawal.time')" header-align="center" align="center"></el-table-column>
        <el-table-column prop="examineTime" :label="$t('withdrawal.examineTime')" header-align="center" align="center"></el-table-column>
        <el-table-column :label="$t('handle')" fixed="right" header-align="center" align="center" width="150">
          <template slot-scope="scope">
            <el-button v-if="$hasPermission('sys:withdrawal:update')" type="text" size="small" @click="addOrUpdateHandle(scope.row.id)">{{ $t('review') }}</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './withdrawal-add-or-update'
export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/sys/withdrawal/page',
        getDataListIsPage: true,
        exportURL: '/sys/withdrawal/export',
        deleteURL: '/sys/withdrawal',
        deleteIsBatch: true
      },
      srcList: ["https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"],
      dataForm: {
        id: ''
      }
    }
  },
  methods: {
    bigImg(url) {
      this.srcList[0] = url;
    }
  },
  components: {
    AddOrUpdate
  }
}
</script>
